<?php
/**
 * 教室信息类
 */
namespace app\admin\controller;

use think\App;
use think\facade\View;

class Article extends Content
{

    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    public function index()
    {
        parent::index();
        return view('content/index');
    }

    public function add(){
        $showData = parent::add();
        if($this->id){
            $showData['id'] = $this->id;
            $showData['detail'] = $this->localModel->findDetaiById('*', $this->id);
            $showData['detail']['tags'] = explode(',', $showData['detail']['tags']);
            $showData['scfData'] = $this->cfmodel->findAllInfo('id, name', [['status', '=', 1], ['level', '=', 2], ['fid', '=', $showData['detail']['cid']]]);
            View::assign($showData);
            return view('content/edit');
        }else{
            View::assign($showData);
            return view('content/add');
        }
    }

    public function save(){
        $this->type = 1;
        $this->validateType = 'article';
        return parent::save();
    }

}
